<template>
  <el-dialog v-model="dialog.showDialog" :append-to-body="false" :close-on-click-modal="false"
             :destroy-on-close="false" :loading="dialog.loading" :submit-icon="dialog.submitIcon"
             :submit-txt="dialog.submitTxt"
             :title="dialog.title" class="avue-dialog avue-crud__dialog" draggable width="1200">
    <basic-crud :apiListParams="listPatrams" :autoLoad="false" :option="option">
      <template #menu-left>
        <el-button icon="user" plain type="primary">批量设置操作员</el-button>
        <el-button icon="user" plain type="primary">批量设置检验员</el-button>
      </template>
    </basic-crud>
    <template #footer>
      <div class="dialog-footer avue-dialog__footer footer_box">
        <el-button
            :icon="dialog.submitIcon"
            type="primary"
            @click="submitDialog"
        >{{ dialog.submitTxt }}
        </el-button>
        <el-button
            icon="el-icon-circle-close"
            @click="cancleDialog"
        > 取消
        </el-button
        >
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import {computed, defineExpose} from 'vue'

const dialog = ref({
  showDialog: false,
  title: "新增",
  submitTxt: "保存",
  submitIcon: "el-icon-circle-check",
  loading: false,
})

// 打开新增编辑对话框
const openDialog = () => {
  dialog.value.showDialog = true;
};

const option = ref({
  highlightCurrentRow: true,
  size: 'small',
  height: 'auto',
  addBtn: false,
  isTableTree: true,
  calcHeight: 200,
  column: [
    {
      label: "工步号",
      prop: "code",
    },
    {
      label: "工步名称",
      prop: "name",
    },
    {
      label: "操作者",
      prop: "workerName",
      width: 200,
      labelWidth: 140,
      slot: true,
      formslot: true,
    },
    {
      label: "检验员",
      prop: "checkerName",
      width: 200,
      labelWidth: 140,
      slot: true,
      formslot: true,
    },
    {
      label: "是否固定军检",
      prop: "fixedArmyFlag",
      width: 200,
      type: "select",
      labelWidth: 140,
      dicData: [
        {
          label: "是",
          value: "true",
        },
        {
          label: "否",
          value: "false",
        },
      ],
      formatter: function (d) {
        if (d.fixedArmyFlag == "true") {
          return "是";
        } else if (d.children && d.children.length > 0) {
          return "";
        } else if (d.fixedArmyFlag == "false") {
          return "否";
        } else {
          return "";
        }
      },
    },
  ],
});

const listPatrams = ref({});

defineExpose({
  openDialog
})

</script>

<style lang="scss" scoped>

</style>
